
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Rectangle.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Rectangle_calculateArea)
{
    TEST(Input length: 2.345, width: 1.5, the area of rectangle should be : 2.34 * 1.5 = 3.51)
    {
        Rectangle rectangle(2.345, 1.5);
        ASSERT_EQ(3.51, rectangle.calculateArea());
    }

    TEST(Input length: 2.345, width: 2.345, the area of rectangle should be: 2.34 * 2.34 = 5.4756,approximately equals 5.48)
    {
        Rectangle rectangle(2.345, 2.345);
        ASSERT_EQ(5.48, rectangle.calculateArea());
    }
   
    TEST(the length and width can be set, the area of rectangle should be: 20 * 30 = 600)
    {
        Rectangle rectangle(2.345, 2.345);
        rectangle.setLength(30);
        rectangle.setWidth(20);
        ASSERT_EQ(600, rectangle.calculateArea());
    }

    TEST(the input length and width are invalid, the area of rectangle should be: 5.48)
    {
        Rectangle rectangle(2.345, 2.345);
        rectangle.setLength(300);
        rectangle.setWidth(200);
        ASSERT_EQ(5.48, rectangle.calculateArea());
    }

    TEST(Input length: 100, width: 75.0045, the area of rectangle should be 100 * 75 = 7500)
    {
        Rectangle rectangle(100, 75);
        ASSERT_EQ(7500, rectangle.calculateArea());
    }

    TEST(Input length: 2.345, width: 1000, the area of rectangle should be 0)
    {
        Rectangle rectangle(2.345, 1000);
        ASSERT_EQ(0, rectangle.calculateArea());
    }

    TEST(Input length: -5, width: 10, the area of rectangle should be 0)
    {
        Rectangle rectangle(-5, 10);
        ASSERT_EQ(0, rectangle.calculateArea());
    } 

    TEST(Input length: -5, width: 1000, the area of rectangle should be 0)
    {
        Rectangle rectangle(-5, 1000);
        ASSERT_EQ(0, rectangle.calculateArea());
    } 
};

FIXTURE(Rectangle_calculatePerimeter)
{ 
    TEST(Input length: 2.345, width: 1.5, the primeter of rectangle should be: (2.34 + 1.5) * 2 = 7.68)
    {
        Rectangle rectangle(2.345, 1.5);
        ASSERT_EQ(7.68, rectangle.calculatePerimeter());
    }

    TEST(Input length: 2.345, width: 2.345, the primeter of rectangle should be: (2.34 + 2.34) * 2 = 9.36)
    {
        Rectangle rectangle(2.345, 2.345);
        ASSERT_EQ(9.36, rectangle.calculatePerimeter());
    }
 
    TEST(the length and width can be set, the area of rectangle should be: (20 + 30) = 100)
    {
        Rectangle rectangle(2.345, 2.345);
        rectangle.setLength(30);
        rectangle.setWidth(20);
        ASSERT_EQ(100, rectangle.calculatePerimeter());
    }

    TEST(the length and width are invalid, the area of rectangle should be: 2.34 * 4=9.36)
    {
        Rectangle rectangle(2.345, 2.345);
        rectangle.setLength(300);
        rectangle.setWidth(200);
        ASSERT_EQ(9.36, rectangle.calculatePerimeter());
    }

    TEST(Input length: 100, width: 75.0045, the primeter of rectangle should be: (100 + 75) * 2 = 350)
    {
        Rectangle rectangle(100, 75.0045);
        ASSERT_EQ(350, rectangle.calculatePerimeter());
    }

    TEST(Input length: 2.345, width: 1000, the primeter of rectangle should be 0)
    {
        Rectangle rectangle(2.345, 1000);
        ASSERT_EQ(0, rectangle.calculatePerimeter());
    }

    TEST(Input length: -5, width: 10, the primeter of rectangle should be 0)
    {
        Rectangle rectangle(-5, 10);
        ASSERT_EQ(0, rectangle.calculatePerimeter());
    }   

    TEST(Input length: -5, width: 1000, the primeter of rectangle should be 0)
    {
        Rectangle rectangle(-5, 1000);
        ASSERT_EQ(0, rectangle.calculatePerimeter());
    } 
};




